<template>
  <div id="AsnDetail">
    <div class="detail">
      <v-navMenu :detailNav="detailNav"
                 :menuData="menuData"
                 @setMentActive="setMentActive"></v-navMenu>
      <component :inputData="detailData"
                 :is="currentComponent"
                 ref=comRef></component>
    </div>
  </div>

</template>

<script>
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Detail",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: false,
      selectData: {},
      detailData: {},
      detailNav: "1",
      menuData: [
        { label: this.$t('common.detail'), index: "1" },
        { label: this.$t('out.PickNotes'), index: "2" },
      ],
      componentConfig: [
        {
          name: "PickDetail",
          label: this.$t('common.info'),
          component: () => import('./page/PickDetail.vue')
        },
        {
          name: "PickNotes",
          label: this.$t('out.PickNotes'),
          component: () => import('./page/PickNotes.vue')
        }
      ]
    }
  },
  computed: {
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    setMentActive (key) {
      this.detailNav = key;
    },
  },
  mounted () {
    this.newFlag = this.$store.state.newFlag
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.detailNav = data.detailNav;
    } else if (this.newFlag) {
      this.detailData = {
        caseid: " ",
        pickheaderkey: " ",
        altsku: " ",
        uom: " ",
        uomqty: 0,
        qty: 0,
        qtymoved: 0,
        status: "0",
        dropid: " ",
        loc: "UNKNOWN",
        id: " ",
        packkey: " ",
        updatesource: "0",
        toloc: " ",
        doreplenish: "N",
        replenishzone: " ",
        docartonize: "N",
        pickmethod: " ",
        wavekey: " ",
        forte_Flag: "I",
        fromloc: " ",
        isclosed: "N",
        qcstatus: "P",
        seqno: 99999,
        qtyrejected: 0,
        statusrequired: "OK",
        tarewgt: 0,
        netwgt: 0,
        grosswgt: 0
      }
    } else {
      this.detailData = this.$store.state.routeData;
    }

  },
  components: {
    "v-navMenu": navMenu,
  },

}
</script>

<style scoped>
</style>
